import Cookies from 'js-cookie'
import { getOriginHrefORHostName } from './getRootCookie'
const TokenKey = 'Admin-Token'

export function getToken() {
  // 获取的域名更改为根域
  return Cookies.get(TokenKey, { domain: `${getOriginHrefORHostName()}` })
}

export function setToken(token) {
  // eslint-disable-next-line no-undef
  return Cookies.set(TokenKey, token, {
    domain: `${getOriginHrefORHostName()}`
  })
}

export function removeToken() {
  // eslint-disable-next-line no-undef
  // 清除当前域token
  Cookies.remove(TokenKey)
  return Cookies.remove(TokenKey, { domain: `${getOriginHrefORHostName()}` })
}
